local cuochong = fk.CreateSkill {
  name = "lingling__cuochong",
}

Fk:loadTranslationTable{
  ["lingling__cuochong"] = "错宠",
  [":lingling__cuochong"] = "当一名角色翻至背面后，其可以令你摸一张牌或弃置一张牌。",

  ["#lingling__cuochong-choice"] = "错宠：你可以令 %src 执行一项",
  ["lingling__cuochong_draw"] = "%src摸一张牌",
  ["lingling__cuochong_discard"] = "%src弃置一张牌",
}

cuochong:addEffect(fk.TurnedOver, {
  anim_type = "control",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(cuochong.name) and
      not target.dead and not target.faceup
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local all_choices = {
      "lingling__cuochong_draw:"..player.id,
      "lingling__cuochong_discard:"..player.id,
      "Cancel",
    }
    local choices = table.simpleClone(all_choices)
    if player:isNude() then
      table.remove(choices, 2)
    end
    local choice = room:askToChoice(target, {
      choices = choices,
      skill_name = cuochong.name,
      prompt = "#lingling__cuochong-choice:"..player.id,
      all_choices = all_choices,
    })
    if choice ~= "Cancel" then
      room:doIndicate(target, {player})
      event:setCostData(self, {choice = choice})
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    if event:getCostData(self).choice:startsWith("lingling__cuochong_draw") then
      player:drawCards(1, cuochong.name)
    else
      room:askToDiscard(player, {
        min_num = 1,
        max_num = 1,
        include_equip = true,
        skill_name = cuochong.name,
        cancelable = false,
      })
    end
  end,
})

return cuochong
